DBMS (Part 1)

*1. What is DBMS?*

Answer:
A Database Management System (DBMS) is software that allows users to create, store, retrieve, update, and manage data efficiently.

Instead of storing data in files, DBMS organizes data into tables and provides security, consistency, and efficient retrieval.

Examples:
• MySQL
• Oracle
• SQL Server
• PostgreSQL
• SQLite

━━━━━━━━━━━━━━━━━━━━

*2. Why do we need DBMS?*

Answer:
Without DBMS:
• Data Redundancy
• Data Inconsistency
• Difficult Searching
• Poor Security
• No Backup
• No Concurrency

DBMS solves all these problems.

━━━━━━━━━━━━━━━━━━━━

*3. Advantages of DBMS*

Answer:
• Reduces Data Redundancy
• Prevents Data Inconsistency
• Better Security
• Backup & Recovery
• Data Sharing
• Concurrency Control
• Data Integrity
• Easy Data Retrieval

━━━━━━━━━━━━━━━━━━━━

*4. What is a Database?*

Answer:
A database is an organized collection of related data.

Examples:
• Student Database
• Employee Database
• Hospital Database

━━━━━━━━━━━━━━━━━━━━

*5. What is RDBMS?*

Answer:
RDBMS (Relational Database Management System) stores data in tables.

The tables are connected using relationships.

Examples:
• MySQL
• Oracle
• PostgreSQL
• SQL Server

━━━━━━━━━━━━━━━━━━━━

*6. Difference Between DBMS and RDBMS*

DBMS
• Stores data
• No relationships
• Less secure
• Normalization not mandatory
• Example: File System

RDBMS
• Stores data in tables
• Relationships exist
• More secure
• Uses normalization
• Example: MySQL

━━━━━━━━━━━━━━━━━━━━

*7. What is SQL?*

Answer:
SQL (Structured Query Language) is used to communicate with databases.

It is used to:
• Create
• Read
• Update
• Delete

database records.

━━━━━━━━━━━━━━━━━━━━

*8. Types of SQL Commands*

*DDL (Data Definition Language)*
Used to define database structure.

Commands:
• CREATE
• ALTER
• DROP
• TRUNCATE
• RENAME

*DML (Data Manipulation Language)*
Used to manipulate data.

Commands:
• INSERT
• UPDATE
• DELETE

*DQL (Data Query Language)*
Used to retrieve data.

Command:
• SELECT

*DCL (Data Control Language)*
Used to control permissions.

Commands:
• GRANT
• REVOKE

*TCL (Transaction Control Language)*
Used to manage transactions.

Commands:
• COMMIT
• ROLLBACK
• SAVEPOINT

━━━━━━━━━━━━━━━━━━━━

*9. What is a Table?*

Answer:
A table stores related data in rows and columns.

━━━━━━━━━━━━━━━━━━━━

*10. What is a Row?*

Answer:
A row represents one complete record in a table.

Example:
Student ID: 101
Name: Ravi
Age: 20

The entire row represents one record.

━━━━━━━━━━━━━━━━━━━━

*11. What is a Column?*

Answer:
A column represents one attribute of an entity.

Examples:
• Student Name
• Age
• Department

━━━━━━━━━━━━━━━━━━━━

*12. What is a Schema?*

Answer:
A schema is the logical structure of a database.

It contains:
• Tables
• Views
• Indexes
• Constraints

━━━━━━━━━━━━━━━━━━━━

*13. What is a Primary Key?*

Answer:
A Primary Key uniquely identifies every row in a table.

Properties:
• Unique
• Cannot be NULL
• Only one Primary Key per table

Example:
StudentID

━━━━━━━━━━━━━━━━━━━━

*14. What is a Foreign Key?*

Answer:
A Foreign Key connects two tables and maintains Referential Integrity.

Example:
Student Table
Department Table

DepartmentID acts as the Foreign Key.

━━━━━━━━━━━━━━━━━━━━

*Difference Between Primary Key and Foreign Key*

Primary Key
• Unique
• Cannot be NULL
• Identifies each row
• One per table

Foreign Key
• Can contain duplicate values
• Can be NULL
• Creates relationships
• Multiple Foreign Keys allowed

━━━━━━━━━━━━━━━━━━━━

*15. What is a Candidate Key?*

Answer:
A Candidate Key is a column (or set of columns) that is eligible to become the Primary Key.

Example:
• Roll Number
• Email

Both are unique and can be chosen as the Primary Key.

━━━━━━━━━━━━━━━━━━━━

*16. What is a Super Key?*

Answer:
A Super Key is a set of one or more attributes that uniquely identifies a record.

Examples:
• StudentID
• StudentID + Name

━━━━━━━━━━━━━━━━━━━━

*17. What is an Alternate Key?*

Answer:
An Alternate Key is a Candidate Key that is not selected as the Primary Key.

━━━━━━━━━━━━━━━━━━━━

*18. What is a Composite Key?*

Answer:
A Composite Key is a Primary Key formed using two or more columns.

Example:
StudentID + SubjectID

━━━━━━━━━━━━━━━━━━━━

*19. What are Constraints?*

Answer:
Constraints are rules applied to data to maintain accuracy and integrity.

Types:
• PRIMARY KEY
• FOREIGN KEY
• NOT NULL
• UNIQUE
• CHECK
• DEFAULT

━━━━━━━━━━━━━━━━━━━━

*20. What is Normalization?*

Answer:
Normalization is the process of removing redundant data and improving database consistency.

*1NF (First Normal Form)*
• No repeating groups
• Atomic values only

*2NF (Second Normal Form)*
• Must satisfy 1NF
• Removes Partial Dependency

*3NF (Third Normal Form)*
• Must satisfy 2NF
• Removes Transitive Dependency
• Most commonly used normalization level

*BCNF (Boyce-Codd Normal Form)*
• A stronger version of 3NF

━━━━━━━━━━━━━━━━━━━━

*Quick Revision*

• DBMS → Database Management System
• RDBMS → DBMS with tables & relationships
• SQL → Structured Query Language
• DDL → CREATE, ALTER, DROP, TRUNCATE, RENAME
• DML → INSERT, UPDATE, DELETE
• DQL → SELECT
• DCL → GRANT, REVOKE
• TCL → COMMIT, ROLLBACK, SAVEPOINT
• Primary Key → Unique Identifier
• Foreign Key → Creates Relationship
• Candidate Key → Eligible Primary Key
• Super Key → Unique Identifier Set
• Alternate Key → Unselected Candidate Key
• Composite Key → Multiple Columns as Primary Key
• Constraints → Rules for Data Integrity
• Normalization → Removes Redundancy